<template>
  <Popup
    v-model:show="showPopup"
    position="bottom"
    :style="{ background: 'transparent', overflow: 'hidden' }"
  >
    <div class="phone-box">
      <img src="@/assets/image/phone-heard.png" class="phone-box-heard" />
      <div class="phone-body-box">
        <div class="phone-body-heard">共育任务</div>
        <div class="phone-content">
          加入亲子共育任务，拉近心与心的距离！周末时光，让我们陪伴孩子阅读童书的奇幻，辅导作业中的成长，跳绳中的欢笑，户外运动的活力，探索旅行的自由，以及游戏间的快乐，家长和孩子一起，创造美好记忆！
        </div>
        <div class="phone-content">
          请你选择您要完成的共育任务，选择完成后不可更改。
        </div>
        <div class="phone-flex-box">
          <div class="item">
            <div class="co-breeding-text">户外活动</div>
            <div
              class="co-breeding-button"
              @click="selectChildTask('12', '户外活动')"
            >
              选择
            </div>
            <img
              src="@/assets/image/co-breeding-one.png"
              class="co-breeding-image"
            />
          </div>
          <div class="item">
            <div class="co-breeding-text">跳绳<br />一百下</div>
            <div
              class="co-breeding-button"
              @click="selectChildTask('13', '跳绳一百下')"
            >
              选择
            </div>
            <img
              src="@/assets/image/co-breeding-two.png"
              class="co-breeding-image"
            />
          </div>
          <div class="item">
            <div class="co-breeding-text">探索旅行</div>
            <div
              class="co-breeding-button"
              @click="selectChildTask('14', '探索旅行')"
            >
              选择
            </div>
            <img
              src="@/assets/image/co-breeding-three.png"
              class="co-breeding-image"
            />
          </div>
          <div class="item">
            <div class="co-breeding-text">童书阅读</div>
            <div
              class="co-breeding-button"
              @click="selectChildTask('15', '童书阅读')"
            >
              选择
            </div>
            <img
              src="@/assets/image/co-breeding-four.png"
              class="co-breeding-image"
            />
          </div>
        </div>
        <!-- <div class="phone-bottom-button">换一换</div> -->
      </div>
    </div>
  </Popup>
</template>
<script lang="ts" setup>
import { useMainStore } from "@/store";
import { Popup } from "vant";
const showPopup = defineModel<boolean>("showPopup");
const mainStore = useMainStore();
const emit = defineEmits(["child-event"]); // Add emit declaration
function selectChildTask(id: string, name: string) {
  mainStore.setCobreedingTaskId(id);
  mainStore.setCobreedingTaskName(name);
  emit("child-event");
}
</script>
<style lang="scss" scoped>
.phone-box {
  width: 358px;
  height: 530px;
  border-radius: 30px 30px 0 0;
  opacity: 1;
  background: #f0a773;
  margin: 0 auto;
  position: relative;
  .phone-body-box {
    position: absolute;
    top: 28px;
    left: 15px;
    width: 328px;
    height: 524px;
    border-radius: 10px;
    background-color: #ffffff;
    .phone-bottom-button {
      width: 173px;
      height: 44px;
      border-radius: 100px;
      opacity: 1;
      background: linear-gradient(90deg, #ffc500 0%, #ffb200 100%);
      box-shadow: inset -1px -1px 2px 0px #d89f37,
        inset 1px 1px 2px 0px rgba(255, 255, 255, 0.3);
      margin: 18px auto;
      display: flex;
      justify-content: center;
      align-items: center;
      font-family: Source Han Sans;
      font-size: 16px;
      font-weight: bold;
      line-height: 28px;
      letter-spacing: 0px;
      font-variation-settings: "opsz" auto;
      color: #ffffff;
    }
    .phone-flex-box {
      display: flex;
      flex-wrap: wrap;
      gap: 11px;
      justify-content: center;
      .item {
        width: 138px;
        height: 121px;
        box-sizing: border-box;
        border-radius: 10px;
        opacity: 1;
        background: #fef2da;
        box-sizing: border-box;
        border: 1px solid #eeb75b;
        position: relative;
        .co-breeding-button {
          width: 48px;
          height: 34px;
          border-radius: 10px;
          opacity: 1;
          background: linear-gradient(90deg, #ffc500 0%, #ffb200 100%);
          box-shadow: inset -1px -1px 2px 0px #d89f37,
            inset 1px 1px 2px 0px rgba(255, 255, 255, 0.3);
          position: absolute;
          bottom: 20px;
          left: 20px;
          display: flex;
          justify-content: center;
          align-items: center;
          font-family: Source Han Sans;
          font-size: 14px;
          font-weight: bold;
          line-height: 22px;
          letter-spacing: 0px;
          font-variation-settings: "opsz" auto;
          color: #ffffff;
        }
        .co-breeding-text {
          font-family: Source Han Sans;
          font-size: 16px;
          font-weight: bold;
          line-height: 20px;
          letter-spacing: 0px;
          font-variation-settings: "opsz" auto;
          color: #e1803b;
          position: absolute;
          top: 17px;
          left: 20px;
        }
        .co-breeding-image {
          position: absolute;
          bottom: 0;
          right: 0;
          width: 66px;
          height: 66px;
        }
      }
    }
    .phone-content {
      width: 293px;
      margin: 4px auto;
      font-family: Source Han Sans;
      font-size: 12px;
      font-weight: 350;
      line-height: 20px;
      letter-spacing: 0px;
      color: #e1803b;
    }
    .phone-body-heard {
      width: 100%;
      height: 42px;
      border-radius: 10px 10px 0px 0px;
      background: #f6c67e;
      font-family: Source Han Sans;
      font-size: 18px;
      font-weight: bold;
      line-height: 32px;
      letter-spacing: 0px;
      font-variation-settings: "opsz" auto;
      color: #ffffff;
      display: flex;
      justify-content: center;
      align-items: center;
    }
  }
  .phone-box-heard {
    position: absolute;
    top: 7px;
    width: 87px;
    height: 16px;
    left: 124px;
  }
  .phone-box-button {
    width: 47.5px;
    height: 47.5px;
    position: absolute;
    bottom: 5px;
    left: 138.51px;
  }
}
</style>
